﻿-- =========================================================================================================
-- Author:		MICHAEL RITACCO
-- Copyright:	2010 MEKHANO GROUP LLC
-- Version:		08/21/2010 1.0
-- =========================================================================================================
CREATE PROCEDURE [flcr].[api_domain_sel]
	@DOMAIN_ID INT = NULL
	,@AUDIT_MOD_USER VARCHAR(100) = NULL
	,@WRKFL_ITEM_ID INT = NULL
	,@WRKFL_STATUS_ID INT = NULL
	,@ACTIVE_FLG BIT = NULL
	,@DOMAIN_NAME VARCHAR(100) = NULL
	,@DOMAIN_DESC VARCHAR(100) = NULL
	
AS
BEGIN

	SELECT	 A.[DOMAIN_ID]
			,A.[AUDIT_USER]
			,A.[AUDIT_DTTM]
			,A.[AUDIT_MOD_USER]
			,A.[AUDIT_MOD_DTTM]
			,A.[RLS_MASK]
			,A.[RLS_OWNER]
			,A.[WRKFL_ITEM_ID]
			,A.[WRKFL_STATUS_ID]
			,A.[ACTIVE_FLG]
			,A.[DOMAIN_NAME]
			,A.[DOMAIN_DESC]
			,A.[PARENT_ID]
	  FROM	[flcr].[DOMAIN] A
	 WHERE	A.[DOMAIN_ID] = COALESCE(@DOMAIN_ID, A.[DOMAIN_ID])
	   AND	A.[AUDIT_MOD_USER] = COALESCE(@AUDIT_MOD_USER, A.[AUDIT_MOD_USER])
	   AND	A.[WRKFL_ITEM_ID] = COALESCE(@WRKFL_ITEM_ID, A.[WRKFL_ITEM_ID])
	   AND	A.[WRKFL_STATUS_ID] = COALESCE(@WRKFL_STATUS_ID, A.[WRKFL_STATUS_ID])
	   AND	A.[ACTIVE_FLG] = COALESCE(@ACTIVE_FLG, A.[ACTIVE_FLG])
	   AND	A.[DOMAIN_NAME] = COALESCE(@DOMAIN_NAME, A.[DOMAIN_NAME])
	   AND	A.[DOMAIN_DESC] = COALESCE(@DOMAIN_DESC, A.[DOMAIN_DESC])
	   
END